﻿using OnlineMealOrdering.Domain.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnlineMealOrdering.Domain
{
    public class PointEntity : AuditableEntity
    {
        public double Point { get; set; }

        public virtual OrderEntity Order { get; set; }

        public EnumPointType Type { get; set; }

        public static PointEntity Create(double point, EnumPointType type, int? orderid = null)
        {
            var entity = new PointEntity();
            entity.Point = point;
            entity.Type = type;
            if (orderid.HasValue)
            {
                var orderentity=DomainContext.Current.EntitySet<OrderEntity>().SingleOrDefault(a=>a.Id==orderid);
                entity.Order = orderentity;
            }
            return entity;
        }
    }
}
